#ifndef __PROPERTY_H__
#define __PROPERTY_H__

#include "dtk_types.h"
#include "dtk_value.h"

typedef enum 
{
    DPP_NORMAL      = 0x00,
    DPP_RDONLY      = 0x01,
    DPP_WRONLY      = 0x02,
    DPP_RDWR        = DPP_RDONLY | DPP_WRONLY,
}DTKAccessProp;


typedef void (*DTKSetProperty) (DTKActor* self, DValue* value, DValue* old_value);
typedef void (*DTKGetProperty) (DTKActor* self, DValue* value);

typedef struct _dtk_property
{
    struct _dtk_property*   next;
    struct _dtk_property*   prev;
    
    DTKAccessProp   access;
    DString         *key;
    DUInt           type;
    DTKSetProperty set_property;
    DTKGetProperty get_property;
}DTKProperty;

typedef struct _dtk_property_manager
{
    DInt            total;
    DTKProperty*    props;
}DTKPropertyManager;

DTKPropertyManager* dtk_propman_create ();
void dtk_propman_release (DTKPropertyManager* self);
void dtk_prop_register(DTKPropertyManager* self,
    DString key, DTKAccessProp access, DUInt type,
    DTKSetProperty set, DTKGetProperty get);
void dtk_prop_set(DTKPropertyManager* self, DTKActor* actor,
    DString key, DValue* value);
void dtk_prop_get(DTKPropertyManager* self, DTKActor* actor,
    DString key, DValue* value);

#endif
